package com.zhuss.controller.order;

import com.zhuss.bean.bo.order.order.SearchOrderItemBo;
import com.zhuss.core.annotation.Anon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.order.order.DetailOrderBo;
import com.zhuss.bean.bo.order.order.SearchOrderBo;
import com.zhuss.common.PageVo;
import com.zhuss.bean.vo.order.order.ListOrderVo;
import com.zhuss.common.BaseController;
import com.zhuss.common.ReadService;
import com.zhuss.order.order.OrderReadServiceExt;
import com.zhuss.exception.DzcxException;
import com.zhuss.order.processor.OrderExport;


/**
 * @description: 订单查询Controller
 * @author: zhushanshuo
 * @create: Mon Jan 11 10:24:29 CST 2021
 **/
@RestController
@RequestMapping("/order")
public class OrderReadController extends BaseController {

	@Autowired
	@Qualifier("orderReadService")
	private ReadService<Object, Object> orderReadService;

	@Autowired
	@Qualifier("orderReadServiceExt")
	private OrderReadServiceExt orderReadServiceExt;

	@Autowired
	private OrderExport orderExport;

	/**
	 * 详情
	 * @param bo
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/detail")
    public Object detail(@RequestBody DetailOrderBo bo) throws DzcxException {

		Object result = orderReadService.detail(bo);
		return result;
    }

	/**
	 * 列表
	 * @param bo
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
    @RequestMapping("/list")
    public Object list(@RequestBody SearchOrderBo bo) throws DzcxException {

		Object result = orderReadService.list(bo);
		return result;
    }
	
	/**
	 * ticket
	 * 列表
	 * @param bo
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/ticketList")
	public Object ticketList(@RequestBody SearchOrderBo bo) throws DzcxException {
		
		Object result = orderReadServiceExt.ticketList(bo);
		return result;
	}

	@ResponseBody
	@RequestMapping(value="/exportOrder")
	@SuppressWarnings("unchecked")
    public Object exportOrder(@RequestBody SearchOrderBo bo) throws DzcxException {
		bo.setPageSize(Integer.MAX_VALUE);
		PageVo<ListOrderVo> pageVo = (PageVo<ListOrderVo>) list(bo);
		return orderExport.process(pageVo.getItems());
    }

	/**
	 * 已售列表
	 * @param bo
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping(value="/soldList")
	public Object soldList(@RequestBody SearchOrderItemBo bo) throws DzcxException {
		Object result = orderReadServiceExt.soldList(bo);
		return result;
	}


}
